import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;

public class justATest4 {
	// Declare the objects and variables to use
	FirefoxDriver driver;
	String baseUrl;
	
	@Before
	public void setUp() throws Exception {
	
		// Main @Before code
		System.out.println("Hello this is @Before every @Test");
		driver = new FirefoxDriver(); // creating an object instance
		baseUrl = "http://www.youtube.com/";
	}
	
	@Test
	public void test1() throws Exception {
		String iSearchTerm; 
		String oSearchResults;
		int iWait;
		
		iWait = 2000;
		
		iSearchTerm = "Selenium";
	
		// All YT related test steps will be performed within this function or method
		//		TC001	Search 	Go To youtube.com
		driver.get(baseUrl); 
		Thread.sleep(iWait);
		//		TC001	Search 	Enter a search term - QTP in the search video field
		// Where part : xpath is "//input[@id='masthead-search-term']"
		// What part : enter text into it.
		driver.findElement(By.xpath("//input[@id='masthead-search-term']")).sendKeys(iSearchTerm);
		Thread.sleep(iWait);
		
		//		TC001	Search	Click the search button or image
		driver.findElement(By.xpath("//button[@id='search-btn']")).click();
		Thread.sleep(iWait);
		Thread.sleep(iWait);
		
		//		TC001	Search	Verify that the results show
		oSearchResults = driver.findElement(By.xpath("//p[@class='num-results']")).getText();
		Thread.sleep(iWait);
		System.out.println("The search numbers are : " + oSearchResults);
				
	}
	
	@After
	public void tearDown() throws Exception {
		System.out.println("Hello this is @After every @Test");
		driver.quit();
	}

}
